//
//  NetLogger.m
//  Ebowin
//
//  Created by 施斌 on 2017/7/19.
//  Copyright © 2017年 ebowin. All rights reserved.
//

#import "NetLogger.h"
#import "MJExtension.h"

@implementation NetLogger


+ (void)logInfoWithRequstApiName:(NSString *)apiName requestParams:(id)requestParams {
#ifdef DEBUG
    NSMutableString *logString = [NSMutableString stringWithString:@"\n\n**************************************************************\n*                       Request Start                        *\n**************************************************************\n\n"];
    [logString appendFormat:@"API Name:%@\n",apiName];
    [logString appendFormat:@"Params:\n%@",[requestParams mj_JSONString]];
    [logString appendFormat:@"\n\n**************************************************************\n*                         Request End                        *\n**************************************************************\n\n\n\n"];
    
    printf("%s",[logString UTF8String]);
    
#endif
}

+ (void)logInfoWithResponseObj:(id)responseObj error:(NSError *)error {
#ifdef DEBUG
    NSMutableString *logString = [NSMutableString stringWithString:@"\n\n**************************************************************\n*                       Response Start                        *\n**************************************************************\n\n"];

    [logString appendFormat:@"content:\n%@",responseObj];
    
    if (error) {
        [logString appendFormat:@"Error Domain:\t\t\t\t\t\t\t%@\n", error.domain];
        [logString appendFormat:@"Error Domain Code:\t\t\t\t\t\t%ld\n", (long)error.code];
        [logString appendFormat:@"Error Localized Description:\t\t\t%@\n", error.localizedDescription];
        [logString appendFormat:@"Error Localized Failure Reason:\t\t\t%@\n", error.localizedFailureReason];
        [logString appendFormat:@"Error Localized Recovery Suggestion:\t%@\n\n", error.localizedRecoverySuggestion];

    }
    
    [logString appendFormat:@"\n\n**************************************************************\n*                         Response End                        *\n**************************************************************\n\n\n\n"];
    
    printf("%s",[logString UTF8String]);
    
#endif
}



@end
